<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>财务批发审核</title>
<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
<style>
body {
	margin: 10px;
}

.demo-carousel {
	height: 300px;
	line-height: 300px;
	text-align: center;
}

.demoTable {
	z-index: 10px;
}

#addReload {
	position: absolute;
	top: 0%;
	z-index: 100px;
	background: rgb(0, 0, 0, 0.9);
	width: 100%;
	height: 100%;
	display: none;
}

#addOperation {
	position: absolute;
	left: 30%;
	top: 15%;
	width: 40%;
	background: white;
}

</style>
</head>
<body>
	<div class="demoTable">
		搜索关键字：
		<div class="layui-inline" >
			<input class="layui-input" name="id" id="demoReload"
				autocomplete="off">
		</div>
		
		时间：
		<div class="layui-input-inline">
      	  	<input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" type="text">
      	</div>
      	——<div class="layui-input-inline">
      	  	<input name="date" id="date1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" type="text">
      	</div>
		<button class="layui-btn" data-type="reload">搜索</button>
		<table class="layui-hide" id="menber" lay-filter="demo"></table>
	</div>
	<div id="addReload">
 		<div id="addOperation">
		 	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  <legend>审核信息填写</legend>
			</fieldset>
			<form class="layui-form" id="shForm" action="../../audit/insertAuditPf.action" method="post"  >
			
			  <div class="layui-form-item">
			    <label class="layui-form-label">审核部门</label>
			    <div class="layui-input-block">
			      <input type="hidden" name="pwId" id="pwId">
			      <input type="hidden" name="auditSection" value="财务部门">
			      <input type="text" maxlength="20" lay-verify="required" value="财务部门" autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
			    </div>
			  </div>
			  <div class="layui-form-item">
			    <label class="layui-form-label">订单名称</label>
			    <div class="layui-input-block">
			      <input type="hidden"  value="0" name="isva">
			      <input type="text" name="roleCode" maxlength="20" value="销售批发订单"  autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
			    </div>
			  </div>
			  <div class="layui-form-item">
			    <label class="layui-form-label">是否通过</label>
			    <div class="layui-input-block" style="width:200px;">
			       <select name="auditPass"  lay-verify="required" lay-filter="isvas" lay-search="" id="isvas">
			       	  <option value="1">是</option>
			          <option value="0">否</option>
			        </select>
			    </div>
			  </div>
			  <div class="layui-form-item layui-form-text" id="auditCause">
			    <label class="layui-form-label">审核意见</label>
				    <div class="layui-input-block">
				      <textarea placeholder="请输入内容" lay-verify="required" maxlength="20" name="auditCause" class="layui-textarea"></textarea>
				    </div>
			  </div>
			  <div class="layui-form-item">
			    <div class="layui-input-block">
			      <input type="submit" class="layui-btn" lay-submit="" lay-filter="roleAdd" value="提交">
			      <button id="closeAdd" type="reset" class="layui-btn layui-btn-primary" >取消</button>
			    </div>
			  </div>
		 </form>
	 </div>
 </div>
	<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="detail" >查看详情</a>
{{# if(d.isva==1){ }}
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">审核</a>
	{{# } else if(d.isva==2){}}
	{{# }else if(d.isva==0){}}
	{{# } }}
  
</script>

	<script src="../../res/js/jquery-1.10.2.js"></script>
	<script src="../../res/js/layui-xtree.js"></script>
	<script src="../../layui/layui.js"></script>
	<script src="../../res/js/base.js"></script>
	<script>

layui.use(['form','laydate', 'laypage', 'layer', 'table', 'upload', 'element','tree'], function(){
  var form = layui.form
  ,laydate = layui.laydate //日期
  ,laypage = layui.laypage //分页
  ,layer = layui.layer //弹层
  ,table = layui.table //表格
  ,upload = layui.upload //上传
  ,element = layui.element; //元素操作
  var path=getRootPath();
  //日期
  laydate.render({
	    elem: '#date'
  });
  laydate.render({
	    elem: '#date1'
  });
  
  //监听Tab切换
  element.on('tab(demo)', function(data){
    layer.msg('切换了：'+ this.innerHTML);
    console.log(data);
  });
  form.on("select(isvas)",function(){
	  if($("#isvas").val()==0){
		  $("#auditCause").attr('lay-verify','');
	  }else{
		  $("#auditCause").attr("lay-verify","required");
	  }
	  
  });
  //执行一个 table 实例
  table.render({
     elem: '#menber'
    ,async: false
    ,height: 474
    ,url: path+'wholesale/findAllCwsh.action' //数据接口
    ,page: true //开启分页
    ,method:'post'
    ,cols: [[ //表头
       {field: 'pfSerialNumber', title: '流水号', width:120}
      ,{field: 'pfNumber', title: '数量', width:120,sort: true}
      ,{field: 'pfTotalMoney', title: '总金额', width:120,sort: true}
      ,{field: 'pfPerson', title: '操作人', width:120,sort: true}
      ,{field: 'pfDates', title: '批发时间', width:150,sort: true}
      ,{field: 'state', title: '状态', width:120,sort: true}
      ,{fixed: 'right',title: '操作', width: 265, align:'center', toolbar: '#barDemo'}
    ]]
  	,id: 'testReload'
  });
  
  //监听工具条
  table.on('tool(demo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
    var data = obj.data //获得当前行数据
    ,layEvent = obj.event; //获得 lay-event 对应的值
    var pfId = data.pfId;
    if(layEvent === 'del'){
      var id=data.pfId;
      $("#pwId").val(id);
      form.render();
      
      $('#addReload').css('display', 'block');
    }else if(layEvent === 'detail'){
    	
    	layer.open({
			title:'批发订单详情'
			,type:2
			,area:['59%','70%']
			,content:path+'pages/yq/wholesaleDetailsh.html?pfId='+pfId
		});
    }
  });
  
		//条件查询
		var $ = layui.$;

		$('.demoTable .layui-btn').on('click', function() {
			var demoReload = $('#demoReload');
			//执行重载
			table.reload('testReload', {
				page : {
					curr : 1
				//重新从第 1页开始
				},
				where : {
					pfPerson : demoReload.val(),
					dateOne: $("#date").val(),
					dateTwo: $("#date1").val(),
				}
			});
		});
		$('#closeAdd').on('click', function() {
			$('#addReload').css('display', 'none');
		});
	});
</script>
</body>
</html>